package com.fjd.controller;

import com.fjd.dto.AssessDTO;
import com.fjd.result.Result;
import com.fjd.service.AssessService;
import com.fjd.vo.AssessVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("AssessController")
@RequestMapping("/shopping/assess")
@Slf4j
@Api(tags = "评论管理")
public class AssessController {
    @Autowired
    private AssessService assessService;


    /**
     * 获取商品评论列表
     */
    @GetMapping("/{productId}")
    @ApiOperation("获取商品评论列表")
    public Result<List<AssessVO>> getAssessList(@PathVariable String productId){
        return Result.success(assessService.list(productId));
    }

    /**
     * 添加商品评论
     * @param assessDTO
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("添加商品评论")
    public Result addAssess(@RequestBody AssessDTO assessDTO){
        assessService.add(assessDTO);
        return Result.success();
    }
}
